/*
 * @Author: 飞越疯人院 353362604@qq.com
 * @Date: 2022-09-22 17:21:22
 * @LastEditors: 飞越疯人院 353362604@qq.com
 * @LastEditTime: 2022-12-16 13:39:47
 * @FilePath: \adminstration\src\Common\Modal\ThrModalList\SampleParameterDetails.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import { API_LIST } from '../../Api/Api'
import { commonTableList } from '../config'
import { TwoAddBtn, SeeEnclosure, ThrDeleteBtn } from '../options'

export const SecurityDetailAttachment = async ({ data, upDataEvent, Permission }) => {
    console.log('三级页权限', Permission)
    let dataList = {
        uuid: data.uuid,
        type: '整改附件列表',
        width: 800,
        classification: 'SelectModal',
        hideInSelect: true,
        hideInSearch: true,
        pageSize: 10,
        params: { pageIndex: 1, SecurityDetailUuid: data.uuid },
        get: API_LIST()['getSecurityDetailAttachment'],
        options: [
            data.handling === 1 &&
                Permission.findIndex(v => v.uuid === 'bcbc660a-cfa9-43cb-b3ba-048514d30c48') !== -1 && (
                    <TwoAddBtn
                        upDataEvent={upDataEvent}
                        title="添加附件"
                        ThrKey="ThrModal"
                        value="SecurityDetailAttachmentDetail"
                        data={data}
                    />
                ),
        ],
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'originalName',
                title: '附件名称',
                valueType: 'input',
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 300,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { fileUrl, uuid } = record
                    return [
                        fileUrl && (
                            <SeeEnclosure
                                key="seeFile"
                                title="查看附件"
                                data={{
                                    className: 'Admin',
                                    url: fileUrl,
                                }}
                            />
                        ),
                        data.handling === 1 && (
                            <ThrDeleteBtn
                                key="delete"
                                additional={[`?SecurityDetailUuid=${data.uuid}&uuid=${uuid}`]}
                                record={data.uuid}
                                upDataEvent={upDataEvent}
                                data={{ key: 'delete', url: 'delSecurityDetailAttachment', title: '删除附件' }}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return dataList
}
